function [prop,topface,targetemochosen,dataOut,dataOut2] = assessEmotionData(data,targetemo)


emotions = {'Angry','Scared','Sad','Calm','Happy','Excited','Centre','Elsewhere'};

% Allocate the mouse pointer to each of the emotions over the timeseries
for i = 1:length(emotions)-1
  [prop(i),dataCat(:,i)] = checkEmo(emotions{i},data);
end

% Some simple differences
alltrue = sum(prop(1:6));
prop(8) = length(data) - sum(prop(1:7));
prop(1:6) = prop(1:6) ./ alltrue;
prop(7:8) = prop(7:8) ./ length(data);
[m,mi] = max(prop(1:6));
dataCat(:,8) = sum(dataCat,2)<1;

% If no face is chosen then we need output checking
if isempty(mi)
  topface = 'None Chosen';
  targetemochosen = 'None Chosen';
else  
  % Otherwise
  topface = emotions{mi};
  targetemochosen = strcmp(topface,targetemo);
end

% ???
% dataOut = cell(length(dataCat)/441,1);
% row = 1;
% for i = 1:441:length(dataCat)
%   index = find(dataCat(i,:));
%   dataOut{row} = emotions{index};
%   dataOut2(row,1:2) = data(i,:);
%   row = row+1;
% end
% 
% 


function [proportion,truevals] = checkEmo(emo,data)

% Get where the emotions are located
[emoPosX,emoPosY, val] = readEmotionPos(emo);
% Check the pointer location
dataTrue(:,1) = (data(:,1) > emoPosX(1)) & (data(:,1) < emoPosX(2));
dataTrue(:,2) = (data(:,2) > emoPosY(1)) & (data(:,2) < emoPosY(2));
% If both are there then it is true
truevals = (dataTrue(:,1) + dataTrue(:,2)) == 2;
% Proportion true to false
proportion = length(find(truevals));

